<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html class="win-frame">
<head>
<title>修改密码</title>
<%@include file="/common/head.jsp" %>
<style>
     #pwd-tip {
         color: #ff0000;            
     }
</style>
</head>
<body>
<div class="form-wrapper">
    <form id="form" method="post">
        <div class="form-cont">
	        <p class="form-cont-title"></p>
	        <span id="pwd-tip" style="text-align:center">&nbsp;</span>
	     </div>
        
        <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>用户名</p>
	        <input type="text" id="username"  class="summer-input" value="${username}"  disabled="disabled"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>当前密码</p>
	        <input type="password" id="curPwd" name="curPwd" class="summer-input summer-validatebox" data-validatebox="validType:['required','password']"> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>新密码</p>
	        <input type="password" id="newPwd" name="newPwd" class="summer-input summer-validatebox" data-validatebox="validType:['required','password']"> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>重复密码</p>
	        <input type="password" id="reNewPwd" class="summer-input summer-validatebox" data-validatebox="validType:['required','password','equalTo[\'#newPwd\']']"> 
	     </div>
         
         <div class="form-btn-wrapper" id="funcbar">
         	<a class="btn btn-normal btn-ok wave distance-right" id="submitBtn">确定</a>
        	<a class="btn btn-normal" id="closeBtn">关闭</a>
    	 </div>
    </form>
</div>
<script>

    $(function () {
      //表单提交事件
      $('#submitBtn').on('click', submit); 
        
      //关闭按钮事件
      $('#closeBtn').on('click',closeWindows);
        
    });
    function submit() {
    	$("#form").form({
       	    buttons : ['#submitBtn'],
            ajax: {
                url: INDEX_CONST_URL.MODIFY_PWD
            },
            onSubmitSuccess: function (data) {
            	var resultData = data.data;
	            if (resultData == 'success') {
	                showSuccess();
	            } else {
	                Tip.show('#pwd-tip', resultData);
	            }
            }
        }).form("submit");
    }    
    
   function showSuccess() {
	   Tip.hide('#pwd-tip');
	   $.stip({
             type:'ok',//显示类型 有info、 ok、 danger
             text: '修改成功, 请重新登录！',
             onBeforeHide: function () {
            	 top.location.href = INDEX_CONST_URL.LOGOUT;
             }
     	});
    }
    
    //关闭窗口
    function closeWindows() {
    	top.$('#modifyPwdWindow').window('close');
    }
    
    var Tip = {
   	    msg: {
   	        cur_pwd_error: '当前密码输入不正确',
   	        unkown_error: '服务器繁忙,请稍后重试',
   	        invalid_pwd : '用户名或密码不正确'
   	    },      
   	    getMsg: function (code) {
   	        return Tip.msg[code] || Tip.msg['unkown_error'];
   	    },
   	    show: function (ele, code) {
   	        $(ele).html(Tip.getMsg(code)).show();
   	    },
   	    hide: function (ele) {
   	        $(ele).hide();
   	    }
    };
    
    //请求url
    var INDEX_CONST_URL = {
        MODIFY_PWD: basePath + '/pwdChange',
        LOGOUT: basePath + "/logout"
    };
</script>
</body>
</html>